package org.ascollada.core
{
	import org.ascollada.ASCollada;
	import org.ascollada.core.log.DaeLogger;
	
	public class DaeVisualScene extends DaeElement
	{
		/** */
		public var nodes	:Array;
		
		/**
		 * 
		 */ 
		public function DaeVisualScene(document:DaeDocument, node:XML=null)
		{
			super(document, node);
		}
		
		/**
		 * Reads the node.
		 * 
		 * @param	node
		 */ 
		public override function read( node:XML ):void
		{
			if ( !validateElement( node.name().localName) )
			{
				DaeLogger.error("Not a " + ASCollada.DAE_VSCENE_ELEMENT + " element!");
				throw new Error("Not a " + ASCollada.DAE_VSCENE_ELEMENT + " element!");
			}
			
			super.read( node );
			
			this.nodes = new Array();
			
			var children:XMLList = node.children();
			var numChildren:int = children.length();
			
			for(var i:int = 0; i < numChildren; i++)
			{
				var child:XML = children[ i ];
				
				switch( child.name().localName )
				{
					case ASCollada.DAE_NODE_ELEMENT:
						this.nodes.push( new DaeNode(this.document, child) );
						break;
						
					default:
						break;
				}
			}
		}
		
		/**
		 * Validate the element to be read.
		 * 
		 * @param	nodeName
		 * 
		 * @return
		 */ 
		public override function validateElement( nodeName:String ) : Boolean
		{
			return (nodeName == ASCollada.DAE_VSCENE_ELEMENT);
		}
	}
}